﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _008_观察者模式
{
    class Mouse
    {
        private string name;
        private string color;
        public Mouse(string name,string color,Cat cat)
        {
            this.name = name;
            this.color = color;
            // 把自身的逃跑方法注册进猫里面
            cat.catCome += RunAway;
        }

        public void RunAway()
        {
            Console.WriteLine($"{color}的老鼠:{name}说老猫来了。快跑！！！");
        }
    }
}
